//
//  PlayMusicView.m
//  段子手
//
//  Created by dllo on 16/3/22.
//  Copyright © 2016年 JokesTeam. All rights reserved.
//

#import "PlayMusicView.h"

#import "AFHTTPRequestOperation.h"
#import "AFHTTPRequestOperationManager.h"
#import "LHYDownLoadManager.h"
#import <AVFoundation/AVFoundation.h>

@interface PlayMusicView ()

@property (nonatomic, retain) UISlider *playTime_slider;

@property (nonatomic, strong) UIVisualEffectView *visualEfView; /**< 毛玻璃 */
@property (nonatomic, retain) UIButton *playButton; /**< 暂停或开始按钮 */
@property (nonatomic, retain) UIButton *downButton; /**< 下一首 */
@property (nonatomic, retain) UIButton *upButton; /** 上一首 */
@property (nonatomic, retain) UIButton *playStayButton; /**< 选择播放状态（顺序，单曲循环，随机播放） */
@property (nonatomic, retain) UIButton *playVolumeButton; /**< 时间设置按钮 */
@property (nonatomic, retain) UIButton *downLoadButton; /**< 下载按钮 */

@property (nonatomic, assign) BOOL isNoVluum; /**< 是否静音 */

@property (nonatomic, retain) UILabel *rightSumTimeLabel; /**< 右边总时长 */
@property (nonatomic, retain) UILabel *leftNowTimeLabel; /**< 左边当前播放时长 */

@property (nonatomic, retain) WXLUrlListModel *nowPlayMusicModel; // 当前播放的音乐
@property (nonatomic, assign) BOOL isPlay; // 当前播放状态
@property (nonatomic, assign) BOOL isStrat; /**< 记录当前转盘转动 */

@property (nonatomic, copy) NSString *str_min; // 最大时长分钟
@property (nonatomic, copy) NSString *str_sec; // 最大时长秒

@property (nonatomic, copy) NSString *str_now_min; // 当前时长分钟
@property (nonatomic, copy) NSString *str_now_sec; // 当前时长秒

@property (nonatomic, copy) NSString *str_title; /**< 标题字 */
@property (nonatomic, retain) UIImageView *bigImage; /**< 大圆图 */
@property (nonatomic, retain) UIImageView *small_onBigImage; /**< 大图上的image */

@property (nonatomic, retain) UIImageView *backgroundImage; /**< 背景图 */
@property (nonatomic, retain) UILabel *titleLabel; /**< 标题lable （歌名） */

@property (nonatomic, assign) NSInteger playStayCount; /**< 用来记录当前的播放状态 */

@property (nonatomic, retain) CABasicAnimation *animation1; // 动画

@property (nonatomic, retain) UIScrollView *scrollView; /**< 底层collectionView */
@property (nonatomic, retain) MusicLyricView *musicLyricView; /**< 歌词view */
@property (nonatomic, retain) UIImageView *animationImageView; /**< 动画image */



@property (nonatomic, retain) AFHTTPRequestOperation *operation1;
@property (nonatomic, assign, getter=isNowDownload) BOOL nowDownload;
@property (nonatomic, retain) UIProgressView *progressV;

@property (nonatomic, copy) NSString *songName;
@property (nonatomic, copy) NSString *singerName;
@property (nonatomic, copy) NSString *songImage;
@property (nonatomic, copy) NSString *songID;
@property (nonatomic, retain) NSMutableArray *arrDownLoad;
@end

@implementation PlayMusicView



/** 创建子视图 */
- (void)createSubView {
    
    // 大圆图
    self.bigImage = [[UIImageView alloc] init];
    
    // 背景
    [self createBackgroundImage];
    
    // 毛玻璃
    [self createVisualEfView];
    
    // slider
    [self createSlider];
   
    // button
    [self createButton];
    
    // 时间
    [self createTimeLabel];
    
    // 标题label
    [self createTitleLabel];
    
    // 滚动视图
    [self createScrollView];
    
    // 创建歌词view
    [self createMusicLyricView];
    
    // 创建动画imageView
    [self createAnimationImageView];
    
    // 开始动画
    [self startAnimation];
    
    self.progressV = [[UIProgressView alloc] initWithProgressViewStyle:(UIProgressViewStyleBar)];
    _progressV.frame =  CGRectMake(10 ,  SCREEN_HETGHT - 10  , SCREEN_WIDTH - 20 , 40 );
    
    // 改变默认高度
    _progressV.transform = CGAffineTransformMakeScale(1.0f, 3.0f);
    _progressV.backgroundColor = [UIColor clearColor];
    _progressV.progressImage = [UIImage imageNamed:@"guangpan"];
    _progressV.trackTintColor = [UIColor clearColor];
    [self addSubview:_progressV];
}

- (void)createAnimationImageView {
    self.animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, _scrollView.frame.size.width, _scrollView.frame.size.height)];
    [_scrollView addSubview:_animationImageView];
    _animationImageView.backgroundColor = [UIColor yellowColor];
    NSMutableArray *imageArr = [NSMutableArray array];
    for (NSInteger i = 1; i <= 30; i++) {
        NSString *str = [NSString stringWithFormat:@"3269368a93ae4838dbe1eefa26833a93－%ld（被拖移）.tiff", i];
        UIImage *image = [UIImage imageNamed:str];
        [imageArr addObject:image];
    }
    _animationImageView.animationImages = imageArr;
    _animationImageView.animationDuration = 2;
    _animationImageView.animationDuration = 0;
    [_animationImageView startAnimating];
}

/** 歌词view */
- (void)createMusicLyricView {
    self.musicLyricView = [MusicLyricView musicLyricView:CGRectMake(_scrollView.frame.size.width * 2, 0, _scrollView.frame.size.width, _scrollView.frame.size.height)];
    [self.scrollView addSubview:_musicLyricView];
}

// 滚动视图
- (void)createScrollView {
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, kUIScreenWidth, kUIScreenHeight - 64 - 150 - 20)];
    self.scrollView.contentSize = CGSizeMake(kUIScreenWidth * 3, 0);
    [self addSubview:_scrollView];
    _scrollView.backgroundColor = [UIColor clearColor];
    _scrollView.pagingEnabled = YES;
    _scrollView.showsHorizontalScrollIndicator = NO;
    _scrollView.contentOffset = CGPointMake(_scrollView.frame.size.width, 0);
}

//图片旋转图片
- (void)startAnimation {
    self.bigImage.frame = CGRectMake(40 + _scrollView.frame.size.width, self.scrollView.center.y - (kUIScreenWidth - 80) / 2 - 40, kUIScreenWidth - 80, kUIScreenWidth - 80);
    [self.scrollView addSubview:_bigImage];
    _bigImage.layer.cornerRadius = _bigImage.frame.size.width / 2;
    _bigImage.layer.masksToBounds = YES;
    _bigImage.image = [UIImage imageNamed:@"guangpan.jpg"];
    
    self.small_onBigImage = [[UIImageView alloc] initWithFrame:CGRectMake(50, 50, kUIScreenWidth - 180, kUIScreenWidth - 180)];
    [_bigImage addSubview:_small_onBigImage];
    _small_onBigImage.layer.cornerRadius = _small_onBigImage.frame.size.width / 2;
    _small_onBigImage.layer.masksToBounds = YES;
    _small_onBigImage.layer.borderWidth = 3;
    _small_onBigImage.layer.borderColor = [UIColor colorWithRed:40 / 225 green:57 / 225 blue:68 / 255 alpha:1].CGColor;
    _small_onBigImage.image = [UIImage imageNamed:@"beijing.jpg"];
    
}

- (void)animation {
    if (!_isPlay) {
        return;
    }
    [self dismissdownView];
}

- (void)dismissdownView {
    if (!self.animation1) {
        //CALayer动画
        self.animation1 = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    }
    //旋转的起始值
    _animation1.fromValue = [NSNumber numberWithFloat:0];
    //旋转的结束值
    _animation1.toValue = [NSNumber numberWithFloat:M_PI * 2];
    //重复次数
    _animation1.repeatCount = NSIntegerMax;
    //时间
    _animation1.duration = 10;
    // 是否自动回到原来位置
    _animation1.autoreverses = NO;
    //是否按照结束为止继续旋转
    _animation1.cumulative = YES;
    [self.bigImage.layer addAnimation:_animation1 forKey:@"zhuan"];
}



- (void)createTitleLabel {
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(44, 20, kUIScreenWidth - 88, 44)];
    [self addSubview:_titleLabel];
    _titleLabel.textColor = [UIColor whiteColor];
    _titleLabel.textAlignment = NSTextAlignmentCenter;
}

- (void)createBackgroundImage {
    self.backgroundImage = [[UIImageView alloc] initWithFrame:self.bounds];
    [self addSubview:_backgroundImage];
    _backgroundImage.alpha = 0.6;
}

- (void)createTimeLabel {
    
    self.rightSumTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(_playTime_slider.frame.size.width + _playTime_slider.frame.origin.x - 100, _playTime_slider.frame.origin.y + 35, 100, 20)];
    [self addSubview:_rightSumTimeLabel];
    _rightSumTimeLabel.backgroundColor = [UIColor clearColor];
    _rightSumTimeLabel.font = [UIFont systemFontOfSize:12];
    _rightSumTimeLabel.textColor = [UIColor whiteColor];
    _rightSumTimeLabel.textAlignment = NSTextAlignmentRight;
    _rightSumTimeLabel.text = @"00:00";
    
    self.leftNowTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake( _playTime_slider.frame.origin.x, _playTime_slider.frame.origin.y + 35, 100, 20)];
    [self addSubview:_leftNowTimeLabel];
    _leftNowTimeLabel.backgroundColor = [UIColor clearColor];
    _leftNowTimeLabel.font = [UIFont systemFontOfSize:12];
    _leftNowTimeLabel.textColor = [UIColor whiteColor];
    _leftNowTimeLabel.textAlignment = NSTextAlignmentLeft;
    _leftNowTimeLabel.text = @"00:00";
}

// 毛玻璃
- (void)createVisualEfView {
    // 毛玻璃
    self.visualEfView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
    _visualEfView.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
    _visualEfView.alpha = 1;
    _visualEfView.userInteractionEnabled = YES;
    
    [self addSubview:_visualEfView];
    
}

- (void)createButton {
    // 该button为最上面的buton
    UIButton *buttonTo = [UIButton buttonWithType:(UIButtonTypeSystem)];
    [self addSubview:buttonTo];
    buttonTo.frame = CGRectMake(10, 25, 34, 34);
    buttonTo.backgroundColor = [UIColor clearColor];
    [buttonTo setBackgroundImage:[UIImage imageNamed:@"iconfont-fanhui-4"] forState:(UIControlStateNormal)];
    [buttonTo addTarget:self action:@selector(buttonToAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    self.playButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
    [self addSubview:_playButton];
    _playButton.frame = CGRectMake(self.center.x - 30, kUIScreenHeight - 90, 60, 60);
    [_playButton setBackgroundImage:[UIImage imageNamed:@"iconfont-bofang-2"] forState:(UIControlStateNormal)];
    [_playButton addTarget:self action:@selector(playButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    self.downButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
    [self addSubview:_downButton];
    _downButton.frame = CGRectMake(self.playButton.frame.origin.x + self.playButton.frame.size.width + 30, self.playButton.frame.origin.y + 10, 40, 40);
    [_downButton setBackgroundImage:[UIImage imageNamed:@"iconfont-suopingxiayiqu"] forState:(UIControlStateNormal)];
    [_downButton addTarget:self action:@selector(downButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    self.upButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
    [self addSubview:_upButton];
    _upButton.frame = CGRectMake(self.playButton.frame.origin.x - 70, self.playButton.frame.origin.y + 10, 40, 40);
    [_upButton setBackgroundImage:[UIImage imageNamed:@"iconfont-suopingshangyiqu"] forState:(UIControlStateNormal)];
    [_upButton addTarget:self action:@selector(upButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    self.playStayButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
    [self addSubview:_playStayButton];
    _playStayButton.frame = CGRectMake(self.upButton.frame.origin.x - 60, self.upButton.frame.origin.y + 5, 30, 30);
    [_playStayButton setBackgroundImage:[UIImage imageNamed:@"iconfont-liebiaoxunhuan"] forState:(UIControlStateNormal)];
    [_playStayButton addTarget:self action:@selector(playStayButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    self.playVolumeButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
    [self addSubview:_playVolumeButton];
    _playVolumeButton.frame = CGRectMake(self.downButton.frame.origin.x + self.downButton.frame.size.width + 30, self.downButton.frame.origin.y + 10, 20, 20);
    if (PLAYMUSIC.volume == 0) {
        _isNoVluum = YES;
        [_playVolumeButton setBackgroundImage:[UIImage imageNamed:@"iconfont-jingyin"] forState:(UIControlStateNormal)];
    } else {
        _isNoVluum = NO;
        [_playVolumeButton setBackgroundImage:[UIImage imageNamed:@"iconfont-yinliangjian"] forState:(UIControlStateNormal)];
    }
    [_playVolumeButton addTarget:self action:@selector(playVolumeButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    self.downLoadButton = [UIButton buttonWithType:UIButtonTypeSystem];
    _downLoadButton.frame = CGRectMake(self.downButton.frame.origin.x + self.downButton.frame.size.width + 30, _playTime_slider.frame.origin.y - 10, 20, 20);
    [self addSubview:_downLoadButton];
    [_downLoadButton setBackgroundImage:[UIImage imageNamed:@"iconfont-xiazai"] forState:(UIControlStateNormal)];
    [_downLoadButton addTarget:self action:@selector(downLoadButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

- (void)createSlider {
    
    self.playTime_slider = [[UISlider alloc] initWithFrame:CGRectMake(10, kUIScreenHeight - 150, kUIScreenWidth - 20, 50)];
    [self addSubview:_playTime_slider];
    // 小球样式
    [_playTime_slider setThumbImage:[UIImage imageNamed:@"iconfont-huakuai"] forState:(UIControlStateNormal)];
    // 改变条颜色 左边条颜色
    _playTime_slider.minimumTrackTintColor = [UIColor whiteColor];
    // 右边条颜色
    _playTime_slider.maximumTrackTintColor = [UIColor lightGrayColor];
    [_playTime_slider addTarget:self action:@selector(sliderAction:) forControlEvents:(UIControlEventValueChanged)];
//    _playTime_slider.transform = CGAffineTransformMakeRotation(1.57079633 * 3);
    
    // 该监听播放进度
    [PLAYMUSIC.avPlayer addPeriodicTimeObserverForInterval:CMTimeMake(1, 1) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) {
        CGFloat duration = CMTimeGetSeconds(PLAYMUSIC.avPlayItem.duration); /**< 获取视频总时间 */
        CGFloat current = CMTimeGetSeconds(PLAYMUSIC.avPlayItem.currentTime);  /**< 获取视频当前时间 */
        
        NSString *durationT = [NSString stringWithFormat:@"%02d:%02d", (int)duration/60, (int)duration%60];
        NSString *currentT = [NSString stringWithFormat:@"%02d:%02d", (int)current/60, (int)current %60];
        
        self.leftNowTimeLabel.text = currentT;
        self.rightSumTimeLabel.text = durationT;
        self.playTime_slider.value = current;
        
        if (current >= duration - 1) {
            [PLAYMUSIC playNextMushic];
        }
    }];
}



#pragma mark - slider 点击方法
- (void)sliderAction:(UISlider *)slider {
    
    [[PlayMusic shareMusic] seekToTime:slider.value];
}



#pragma mark - button点击方法
// 下载按钮点击
- (void)downLoadButtonAction:(UIButton *)button {
    
    // 禁止重复下载
    // 任务1
    self.operation1 = [LHYDownLoadManager downloadFileWithURLString: _nowPlayMusicModel.url
 cachePath:[NSString stringWithFormat:@"%lu.mp3",(unsigned long)[_nowPlayMusicModel.url
 hash]] progress:^(CGFloat progress, CGFloat totalMBRead, CGFloat totalMBExpectedToRead) {
        
        _progressV.alpha = 1;
        _progressV.progress = progress;
        NSLog(@"Task1 -> progress: %.2f -> download: %fMB -> all: %fMB", progress, totalMBRead, totalMBExpectedToRead);
        
    } success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        
        NSDictionary *dic =@{@"image":self.songImage ,@"songName":self.songName,@"singerName":self.singerName,@"filePath": _nowPlayMusicModel.url};
        
        self.downLoadButton.alpha = 0;
        
        NSArray *pathArr = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSLog(@"%@", pathArr);
        NSString *documentPath = [pathArr lastObject];
        NSString *arrPath = [documentPath stringByAppendingPathComponent:@"arrPath.list"];
        
        NSArray *arr = [NSArray arrayWithContentsOfFile:arrPath];
        NSMutableArray *arrM = [NSMutableArray arrayWithArray:arr];
        
        [arrM addObject:dic];
        
        [arrM writeToFile:arrPath atomically:YES];
        
        
        
        NSLog(@"Task1 -> Download finish");
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        _downLoadButton.alpha = 1;
        if (error.code == -999) NSLog(@"Task1 -> Maybe you pause download.");
        if (error) {
            
        }
        NSLog(@"Task1 -> %@", error);
    }];
}



// 声音button
- (void)playVolumeButtonAction:(UIButton *)button {
    if (!_isNoVluum) {
        PLAYMUSIC.volume = 0;
        [_playVolumeButton setBackgroundImage:[UIImage imageNamed:@"iconfont-jingyin"] forState:(UIControlStateNormal)];
        
    } else {
    PLAYMUSIC.volume = 5;
        [_playVolumeButton setBackgroundImage:[UIImage imageNamed:@"iconfont-yinliangjian"] forState:(UIControlStateNormal)];
    }
    _isNoVluum = !_isNoVluum;
}

// 选择播放风格
- (void)playStayButtonAction:(UIButton *)button {
    
    if (_playStayCount == 0) {
        // 顺序循环播放
        PLAYMUSIC.playMusicStye = playMusicStyeSequenceCirculation;
        [_playStayButton setBackgroundImage:[UIImage imageNamed:@"iconfont-liebiaoxunhuan"] forState:(UIControlStateNormal)];
    } else if (_playStayCount == 1) {
        // 随机播放
        PLAYMUSIC.playMusicStye = playMusicStyeRandom;
        [_playStayButton setBackgroundImage:[UIImage imageNamed:@"iconfont-suijibofang"] forState:(UIControlStateNormal)];
    } else if (_playStayCount == 2) {
        // 单曲循环
        PLAYMUSIC.playMusicStye = playMusicStyeSingle;
        [_playStayButton setBackgroundImage:[UIImage imageNamed:@"iconfont-danquxunhuan"] forState:(UIControlStateNormal)];
        _playStayCount = 0;
        return;
    }
    
    _playStayCount++;
}

// 实现返回上一页
- (void)buttonToAction:(UIButton *)button {
    
    [self.delegate buttonToClick];
}

// 播放或暂停
- (void)playButtonAction:(UIButton *)button {
    
    UIImage *imag = [self.delegate playButtonClick:_isPlay];
    if (_isStrat) {
        // 暂停
        CFTimeInterval stopTime = [self.bigImage.layer convertTime:CACurrentMediaTime() fromLayer:nil];
        //
        // 设置动画速度
        self.bigImage.layer.speed = 0;
        // 保存时间的偏移量
        self.bigImage.layer.timeOffset = stopTime;
        
    } else if (!_isStrat && _isPlay) {
        // 继续
        // 找到时间偏移量
        CFTimeInterval stopTime = self.bigImage.layer.timeOffset;
        // 速度设置为1
        self.bigImage.layer.speed = 1;
        // 重置开始时间为0
        self.bigImage.layer.beginTime = 0;
        self.bigImage.layer.timeOffset = 0;
        // 设置开始时间
        self.bigImage.layer.beginTime = [self.bigImage.layer convertTime:CACurrentMediaTime() fromLayer:nil] - stopTime;
    }
    _isStrat = !_isStrat;
    
    [button setBackgroundImage:imag forState:(UIControlStateNormal)];
}

// 下一曲
- (void)downButtonAction:(UIButton *)button {
    
    [PLAYMUSIC downSong];
}

// 上一曲
- (void)upButtonAction:(UIButton *)button {
    
    [PLAYMUSIC upSong];
}




#pragma mark - block 的回调
- (void)callbackFunctionAboutBlock {
    [self playInfoBlock];
    
    [self playIsYesOrNo];
}

// 播放状态
- (void)playIsYesOrNo {
    PLAYMUSIC.blockPlayYesOrNo = ^(BOOL isPlay) {
        _isPlay = isPlay;
        
        if (_isPlay) {
            [_playButton setBackgroundImage:[UIImage imageNamed:@"iconfont-suopingzanting-3"] forState:(UIControlStateNormal)];

        } else {
            [_playButton setBackgroundImage:[UIImage imageNamed:@"iconfont-bofang-2"] forState:(UIControlStateNormal)];
            
        }
        
    };
}

// 从本地获取下载的数组
- (NSMutableArray *)getArr {
    
    NSArray *pathArr = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentPath = [pathArr lastObject];
    NSString *arrPath = [documentPath stringByAppendingPathComponent:@"arrPath.list"];
    
    NSArray *arr = [NSArray arrayWithContentsOfFile:arrPath];
    NSMutableArray *arrM = [NSMutableArray arrayWithArray:arr];
    
    return arrM;
    
}

// 播放信息
- (void)playInfoBlock {
    PLAYMUSIC.blockPlayMusic = ^(WXLUrlListModel *model, NSString *songName, NSString *picUrl, NSString *singerName, NSString *songID, BOOL isPlay) {
        
        self.nowPlayMusicModel = model;
        self.songName = songName;
        self.songImage = picUrl;
        self.singerName = singerName;
        self.songID = songID;
        
        [_musicLyricView dataHandel:model songName:songName singerName:singerName songID:songID];
        
        NSMutableArray *arrTitle = [NSMutableArray array];
        self.arrDownLoad = [self getArr];
        
        for (NSDictionary *dic in self.arrDownLoad) {
            [arrTitle addObject:dic[@"songName"]];
            
        }
        if ([arrTitle containsObject:songName]) {
            
            self.downLoadButton.alpha = 0;
        }else {
            self.downLoadButton.alpha = 1;
        }
        
        _playTime_slider.maximumValue = _nowPlayMusicModel.duration;
        
        NSInteger time = (NSInteger)_nowPlayMusicModel.duration;
        NSInteger min = time / 60;
        NSInteger sex = time % 60;
        
        self.str_min = [NSString stringWithFormat:@"%ld", min];
        self.str_sec = [NSString stringWithFormat:@"%ld", sex];
        
        if (min < 10) {
            self.str_min = [NSString stringWithFormat:@"0%ld", min];
        }
        if (sex < 10) {
            self.str_sec = [NSString stringWithFormat:@"0%ld", sex];
        }
        NSString *time_str = [NSString stringWithFormat:@"%@:%@", self.str_min, self.str_sec];
        _rightSumTimeLabel.text = time_str;
        [_playButton setBackgroundImage:[UIImage imageNamed:@"iconfont-suopingzanting-3"] forState:(UIControlStateNormal)];
        
        [_backgroundImage HANDLEIMAGE(picUrl)];
        [_small_onBigImage HANDLEIMAGE(picUrl)];
        
        self.str_title = [NSString stringWithFormat:@"%@ - %@", songName, singerName];
        _titleLabel.text = _str_title;
        
        [self dismissdownView];
    };
}




+ (PlayMusicView *)plyMusicView {
    
    return [[PlayMusicView alloc] initWithFrame:CGRectMake(0, 0, kUIScreenWidth, kUIScreenHeight)];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
        
        _isStrat = YES;
        
        _playStayCount = 1;
        // block回调
        [self callbackFunctionAboutBlock];
        
        self.backgroundColor =[UIColor lightGrayColor];
    }
    return self;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
